import request from '@/util/request'
import type { RootArtistInfo, RootSong, RootArtistDesc, RootAlbum, RootMv, RootAlbumInfo } from '@/types/artist/index'
import type { ArtistSongQuery, ArtistCommonQuery } from '@/types/common/common'

/**
 * 获取歌手信息
 * @param id
 * @returns
 */
export const getArtistInfo = async (id: number) => {
  return await request.get<RootArtistInfo>(`/artist/detail?id=${id}`)
}

/**
 * 获取歌曲
 * @param id
 * @param order
 * @param limit
 * @param offset
 * @returns
 */
export const getArtistSongs = async ({ id, order, limit, offset }: ArtistSongQuery) => {
  return request.get<RootSong>(`/artist/songs?id=${id}&order=${order}&limit=${limit}&offset=${offset}`)
}

/**
 * 获取歌手详情
 * @param id
 * @returns
 */
export const getArtistDesc = async (id: number) => {
  return await request.get<RootArtistDesc>(`/artist/desc?id=${id}`)
}

/**
 * 获取专辑
 * @param param
 * @returns
 */
export const getArtistAlbum = async ({ id, limit, offset }: ArtistCommonQuery) => {
  return await request.get<RootAlbum>(`/artist/album?id=${id}&limit=${limit}&offset=${offset}`)
}

/**
 * 获取mv
 * @param param
 * @returns
 */
export const getArtistMv = async ({ id, limit, offset }: ArtistCommonQuery) => {
  return await request.get<RootMv>(`/artist/mv?id=${id}&limit=${limit}&offset=${offset}`)
}

/**
 * 获取专辑详情
 * @param id
 * @returns
 */
export const getAlbumInfo = async (id: number) => {
  return await request.get<RootAlbumInfo>(`/album?id=${id}`)
}
